package com.flute.icrawler.app;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.flute.haflute.jobbox.base.RunProcessInterface;
import com.flute.icrawler.app.task.CrawlTaskManager;

public class TaskServer implements RunProcessInterface {

	private static final Logger LOGGER = LoggerFactory
			.getLogger(TaskServer.class);

	private boolean isInitialized = false;

	private CrawlTaskManager crawlTaskManager = null;

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		CrawlTaskManager crawlTaskManager = new CrawlTaskManager();

		LOGGER.info("Begin to start task server");
		crawlTaskManager.start();
		LOGGER.info("Success to start task server !");

	}

	@Override
	public void callMain(String... arg0) throws Exception {
		crawlTaskManager = new CrawlTaskManager();
		if (null == crawlTaskManager) {
			LOGGER.info("Start task server failed!");
		}
		LOGGER.info("Begin to start task server");
		crawlTaskManager.start();
		LOGGER.info("Task server is start");
		isInitialized = true;

	}

	@Override
	public boolean isInitialized() {
		return isInitialized;
	}

	@Override
	public void restart() {

	}

	@Override
	public void shutdown() {
		if (null != crawlTaskManager) {
			crawlTaskManager.beforeShutdown();
		}

	}

}
